package com.wanmait.hotelManage.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.wanmait.hotelManage.util.DBHelper;
import com.wanmait.hotelManage.vo.Userinfo;

public class CommentDAO {
private CommentDAO() {}
	private static CommentDAO CommentDAO=new CommentDAO();
	public static CommentDAO getCommentDAO() {
		return CommentDAO;
	}
	public void addComment(int roomTypeId,int userinfoId,String Content, int parentId) {
		String sql="INSERT into room_type_comment(room_type_id,userinfo_id,content,parent_id) VALUES(?,?,?,?)";
		DBHelper.getDBHelper().executeUpdate(sql,roomTypeId,userinfoId,Content,parentId);
	}
	public void addHoteComment(int userinfoId,String Content, int parentId) {
		
		String sql="INSERT into hotel_comment(userinfo_id,content,parent_id) VALUES(?,?,?)";
		DBHelper.getDBHelper().executeUpdate(sql,userinfoId,Content,parentId);
	}
	public boolean pan(Userinfo userinfo) {
		Connection conn=null;
		PreparedStatement ps=null;
		ResultSet rs=null;
		boolean b=false;
		String sql="SELECT * FROM orders WHERE userinfo_id=?";
		try {
			conn=DBHelper.getDBHelper().getConn();
			ps=conn.prepareStatement(sql);
			ps.setInt(1, userinfo.getId());
			rs=ps.executeQuery();
			b=rs.next();
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return b;
	}
}
